import _ from 'lodash';

export default {
  props: {
    collectProps: {
      type: Object,
      default: () => ({
        type: 'choice',
        fill: 'fill'
      })
    },
    defaultProps: {
      type: Object,
      default: () => ({
        choice: 'choice',
        data: {
          label: 'title',
          value: 'title'
        }
      })
    }
  },

  computed: {
    // 信息收集
    collectInfo() {
      if (this.can_do) return null;

      const check_value = [];

      const { type, fill } = this.collectProps;
      _.forEach(
        this.option,
        ({ field_value, fill_value }) => {
          const index = this.inputValue.indexOf(field_value);
          if (index > -1) {
            check_value.push(
              {
                [type]: field_value,
                [fill]: fill_value
              }
            );
          }
        }
      );

      return {
        field: this.id,
        field_value: {
          check_value
        }
      };
    }
  }
};
